import wepy from 'wepy'
import { api } from './config1'
import { requestData } from './util'

//用户首页 接口
export const indexPage = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.indexPage.url + `?accessToken=${accessToken}`,
      method: api.member.indexPage.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//合同监理支付
export const contractSupervisorPay = (params, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.contractSupervisorPay.url + `?accessToken=${accessToken}`,
      method: api.contract.contractSupervisorPay.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//合同下载中的协议
export const serviceAgreement = (ID, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.downloadContract.serviceAgreement.url + `/${ID}?accessToken=${accessToken}`,
      method: api.downloadContract.serviceAgreement.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//合同监理详情
export const contractDetail = (ID, accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.contractDetail.url + `/${ID}?accessToken=${accessToken}`,
      method: api.contract.contractDetail.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//获取服务协议信息
export const contractServiceAgreement = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.base.serviceAgreement.url + `?accessToken=${accessToken}`,
      method: api.base.serviceAgreement.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//获取合同类型
export const getContractType = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.base.contractType.url + `?accessToken=${accessToken}`,
      method: api.base.contractType.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//获取监理机构列表
export const getAgencyList = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.base.agencyList.url + `?accessToken=${accessToken}`,
      method: api.base.agencyList.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//获取监理支付参数信息
export const contractSupervisorPayInfo = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.payInfo.url + `?accessToken=${accessToken}`,
      method: api.contract.payInfo.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//发送律师函
export const sendLetter = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.sendLetter.url + `?accessToken=${accessToken}`,
      method: api.contract.sendLetter.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//获取被监理方列表
export const getMandatary = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.mandatary.url + `?accessToken=${accessToken}`,
      method: api.contract.mandatary.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//余额充值
export const recharge = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.recharge.url + `?accessToken=${accessToken}`,
      method: api.member.recharge.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//套餐获取
export const setMeal = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMeal.url + `?accessToken=${accessToken}`,
      method: api.member.setMeal.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//套餐列表获取
export const setMealList = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMealList.url + `?accessToken=${accessToken}`,
      method: api.member.setMealList.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//套餐购买确认支付
export const setMealPay = (params) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMealPay.url,
      method: api.member.setMealPay.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//套餐充值
export const setMealRecharge = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMealRecharge.url + `?accessToken=${accessToken}`,
      method: api.member.setMealRecharge.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//获取律师费
export const attorneyMoney = (accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.base.attorneyMoney.url + `?accessToken=${accessToken}`,
      method: api.base.attorneyMoney.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//违约操作中选择中介确定
export const chooseAgency = (params,ID,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.agency.url + `/${ID}?accessToken=${accessToken}`,
      method: api.contract.agency.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//违约操作中选择中介信息
export const chooseAgencyInfo = (ID,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.chooseAgencyInfo.url + `/${ID}?accessToken=${accessToken}`,
      method: api.contract.chooseAgencyInfo.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//分享朋友圈的单个被监理人信息
export const getOneMandatary = (ID,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.mandatary.url + `/${ID}?accessToken=${accessToken}`,
      method: api.contract.mandatary.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//舆论创建
export const buildConsensus = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.buildConsensus.url + `?accessToken=${accessToken}`,
      method: api.contract.buildConsensus.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//套餐消费记录剩余信息
export const setMealInfo = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMealInfo.url + `?accessToken=${accessToken}`,
      method: api.member.setMealInfo.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//套餐消费记录列表
export const setMealRecord = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMealRecord.url + `?accessToken=${accessToken}`,
      method: api.member.setMealRecord.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//套餐是否过期
export const setMealOverdue = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMealOverdue.url + `?accessToken=${accessToken}`,
      method: api.member.setMealOverdue.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//购买套餐 续费或者升级
export const setMealUpgrade = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.setMealUpgrade.url + `?accessToken=${accessToken}`,
      method: api.member.setMealUpgrade.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//合同详情中的 操作记录
export const contractLogs = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.contractLogs.url + `?accessToken=${accessToken}`,
      method: api.contract.contractLogs.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//获取招标详情
export const supervisorDetail = (ID,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.contract.chooseAgencyInfo.url + `/${ID}?accessToken=${accessToken}`,
      method: api.contract.chooseAgencyInfo.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}
//积分接口
export const integral = (params,accessToken) => {
  return new Promise((resolve, reject) => {
    requestData({
      url: api.member.integral.url + `?accessToken=${accessToken}`,
      method: api.member.integral.method,
      header: {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
      },
      data: params
    }, function(data) {
      resolve(data)
    }, function(error) {
      resolve(error)
    })
  })
}